Incremental compilation of finite automata for a regular expression accelerator

ABSTRACT

A compiler/loader unit for a RegEx accelerator is described that receives a first set of regular expression rules for implementing the RegEx accelerator, generates, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph, and generates, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator. The compiler/loader unit receives receive, a second set of one or more new or modified regular expression rules for implementing the RegEx accelerator and in response performs incremental compilation of the second set of regular expressions. The compiler/loader unit generates, based on the second set of one or more regular expression rules, a supplemental DFA graph and reconciles the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.

TECHNICAL FIELD

The disclosure relates to processing packets of information, for example, in the fields of networking and storage.

BACKGROUND

In a typical computer network, a large collection of interconnected servers provides computing and/or storage capacity for execution of various applications. A data center is one example of a large-scale computer network and typically hosts applications and services for subscribers, i.e., customers of the data center. The data center may, for example, host all of the infrastructure equipment, such as compute nodes, networking and storage systems, power systems, and environmental control systems. In most data centers, clusters of storage systems and application servers are interconnected via a high-speed switch fabric provided by one or more tiers of physical network switches and routers. Data centers vary greatly in size, with some public data centers containing hundreds of thousands of servers, and are usually distributed across multiple geographies for redundancy.

Many devices within a computer network, e.g., storage/compute servers, firewalls, intrusion detection devices, switches, routers or other network attached devices, often use general purpose processors, including multi-core processing systems, to process data, such as network or storage data. However, general purpose processing cores and multi-processing systems are normally not designed for high-capacity network and storage workloads of modern networks and can be relatively poor at performing packet stream processing.

SUMMARY

In general, this disclosure describes a highly programmable device, referred to generally as a data processing unit, having multiple processing units for processing streams of information, such as network packets or storage packets. In some examples, the processing units may be processing cores, and in other examples, the processing units may be virtual processors, hardware threads, hardware blocks, or other sub-processing core units. As described herein, the data processing unit includes one or more specialized hardware-based accelerators configured to perform acceleration for various data-processing functions, thereby offloading tasks from the processing units.

In various examples, this disclosure describes a programmable, hardware-based accelerator unit configured to apply and evaluate regular expressions against high-speed data streams. The accelerator unit may include a hardware implementation of a regular expression (RegEx) evaluator, and thus, may be referred to herein as a RegEx accelerator unit, or simply a RegEx accelerator. In particular, the RegEx accelerator unit may be configured to process one or more deterministic finite automata (DFA) to evaluate regular expressions against particular data units of the data streams. Regular expressions generally define a pattern of characters, expressed in a regular language, to be identified in an input sequence of characters, such as one or more payloads of one or more packets. The RegEx accelerator of this disclosure may be configured to identify occurrences of one or more target strings defined by one or more respective regular expressions in a set of one or more payloads of packets using one or more DFAs. The RegEx accelerator may be used as part of various data processing services, such as intrusion detection and prevention (IDP), anti-virus scanning, search, indexing, and the like.

In some examples, this disclosure describes techniques for incrementally compiling regular expression rules into a DFA graph. In one example a compiler/loader unit includes a builder stage and a mapper stage. The builder stage generates a machine-independent DFA graph based on an input of one or more regular expression rules. The mapper stage generates a machine-dependent image (e.g., data structure arrangement) of the DFA graph that will subsequently be loaded into a processing unit memory (e.g., L1 cache, L2 cache, external memory, and the like) of an example RegEx accelerator.

When a user wants to re-configure the example RegEx accelerator to evaluate one or more additional and/or modified regular expression rules, rather than recompile the entire machine-independent DFA graph all over again to handle the additional or modified regular expression rules, the example compiler/loader unit may instead perform an incremental compilation process to improve compilation efficiency. For example, after having already compiled one or more regular expression rules into an original DFA graph that is then mapped to an initial memory image for the hardware-based RegEx accelerator, the example compiler/loader unit may receive one or more additional or modified regular expression rules that the example RegEx accelerator will need to evaluate. The compiler/loader unit may generate a supplemental machine-independent DFA graph for just the additional or modified regular expression rules. In some examples, the supplemental DFA graph may be larger or smaller than the original DFA graph. The compiler/loader may then perform a union operation between the original machine-independent DFA graph and the supplemental machine-independent DFA graph combine the two graphs while eliminating any overlap between the two machine-independent DFA graphs. In response to the union operation, the compiler/loader may output an updated machine-dependent memory image of the union between the original and supplemental DFA graphs.

In this way, rather than recompiling and regenerating an entire machine-dependent DFA graph every time new or modified regular expression rules are provided for an example hardware-based RegEx accelerator, the example compiler/loader unit may build off work already performed when previously compiling and generating an original DFA graph to subsequently compile a new or updated DFA graph. Because building of a DFA graph is a very computationally intensive task, the example compiler/loader unit need not have to recompile all the regular expression rules whenever new expression rules are added or modified. Instead, the example compiler/loader unit need only compile new or modified regular expression rules and perform a union operation between original machine-independent DFA graph and the supplemental machine-independent DFA graph to map a single machine-dependent DFA graph to a memory architecture for the particular hardware-based RegEx accelerator, which can be computationally intensive. Such incremental compilation techniques may be more computationally efficient than recompiling an entire DFA graph every time more regular expression rules are added.

Although generally described as being a compiler/loader unit, in some cases, the compiler/loader unit comprises two or more dedicated units, one being for performing compiling techniques and the other for performing loading or mapping techniques.

In one example, a computing device includes at least one processor configured to execute a compiler/loader unit that is configured to: receive a first set of one or more regular expression rules for implementing a RegEx accelerator; generate, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generate, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receive, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generate, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconcile the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.

In another example, a method is described that includes receiving, at a compiler/loader unit executing at a computing device, a first set of one or more regular expression rules for implementing a RegEx accelerator; generating, by the compiler/loader unit, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generating, by the compiler/loader unit, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receiving, at the compiler, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generating, by the compiler, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconciling, by the compiler, the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.

In another example, a computer-readable storage medium includes instructions that, when executed, cause at least one processor to execute a compiler/loader unit configure to: receive a first set of one or more regular expression rules for implementing a RegEx accelerator; generate, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generate, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receive, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generate, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconcile the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.

The details of one or more examples are set forth in the accompanying drawings and the description below. Other features, objects, and advantages will be apparent from the description and drawings, and from the claims.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating an example system including one or more network devices configured to efficiently process a series of work units in a multiple core processor system.

FIG. 2 is a block diagram illustrating an example data processing unit (DPU) including two or more processing clusters, in accordance with the techniques of this disclosure.

FIG. 3 is a block diagram illustrating another example data processing unit including two or more processing clusters, in accordance with the techniques of this disclosure.

FIG. 4 is a block diagram illustrating an example processing cluster including a plurality of programmable processing cores.

FIG. 5 is a block diagram illustrating an example regular expression (RegEx) accelerator, in accordance with the techniques of this disclosure.

FIG. 6A is a conceptual diagram illustrating an example deterministic finite automata (DFA) graph.

FIG. 6B is a flowchart illustrating an example method for allocating data for nodes of a DFA graph between buffer memory and external memory of a RegEx accelerator, in accordance with the techniques of this disclosure.

FIG. 6C is a conceptual diagram illustrating an example set of memory slices of a buffer memory, including data for arcs of nodes of a DFA graph.

FIGS. 7A through 7C are flowcharts illustrating example regular expression operations performed in accordance with the techniques of this disclosure.

FIG. 8 is a flowchart illustrating an example method for traversing a DFA graph from one node to a next node in accordance with the techniques of this disclosure.

FIG. 9 is a block diagram illustrating an example DFA engine.

FIG. 10A is a conceptual diagram illustrating a compiler/loader unit configured to incrementally compile a set of a regular expressions into a DFA graph, in accordance with the techniques of this disclosure.

FIG. 10B is a conceptual diagram illustrating the compiler/loader unit of FIG. 11A in more detail.

FIG. 10C is a conceptual diagram illustrating aspects of the builder stage of the compiler/loader unit shown in FIGS. 10A and 10B.

FIG. 10D is a flowchart illustrating an example method for incrementally compiling regular expressions into a DFA graph.

DETAILED DESCRIPTION

FIG. 1 is a block diagram illustrating an example system 8 including one or more network devices configured to efficiently process a series of work units in a multiple core processor system. As described herein, techniques for caching and prefetching data from non-coherent memory may provide technical benefits that include improving the efficiency and utilization of processing cores within access nodes 17 in FIG. 1. Access nodes may also be referred to as data processing units (DPUs), or devices including DPUs, in this disclosure. In the example of FIG. 1, various data structures and processing techniques are described with respect to access nodes 17 within a data center 10. Other devices within a network, such as routers, switches, servers, firewalls, gateways and the like, having multiple core processor systems may readily be configured to utilize the data processing techniques described herein.

Data center 10 represents an example of a system in which various techniques described herein may be implemented. In general, data center 10 provides an operating environment for applications and services for customers 11 coupled to the data center by service provider network 7 and gateway device 20. Data center 10 may, for example, host infrastructure equipment, such as compute nodes, networking and storage systems, redundant power supplies, and environmental controls. Service provider network 7 may be coupled to one or more networks administered by other providers, and may thus form part of a large-scale public network infrastructure, e.g., the Internet. In other examples, service provider network 7 may be a data center wide-area network (DC WAN), private network or other type of network.

In some examples, data center 10 may represent one of many geographically distributed network data centers. In the example of FIG. 1, data center 10 is a facility that provides information services for customers 11. Customers 11 may be collective entities such as enterprises and governments or individuals. For example, a network data center may host web services for several enterprises and end users. Other exemplary services may include data storage, virtual private networks, file storage services, data mining services, scientific- or super-computing services, and so on.

In the illustrated example, data center 10 includes a set of storage systems and application servers 12 interconnected via a high-speed switch fabric 14. In some examples, servers 12 are arranged into multiple different server groups, each including any number of servers up to, for example, n servers 12 ₁-12 _(n). Servers 12 provide computation and storage facilities for applications and data associated with customers 11 and may be physical (bare-metal) servers, virtual machines running on physical servers, virtualized containers running on physical servers, or combinations thereof.

In the example of FIG. 1, each of servers 12 is coupled to switch fabric 14 by an access node 17 for processing streams of information, such as network packets or storage packets. In example implementations, access nodes 17 may be configurable to operate in a standalone network appliance having one or more access nodes. For example, access nodes 17 may be arranged into multiple different access node groups 19, each including any number of access nodes up to, for example, x access nodes 17 ₁-17 _(x). In other examples, each access node may be implemented as a component (e.g., electronic chip) within a device, such as a compute node, application server, storage server, and may be deployed on a motherboard of the device or within a removable card, such as a storage and/or network interface card.

In general, each access node group 19 may be configured to operate as a high-performance I/O hub designed to aggregate and process network and/or storage I/O for multiple servers 12. As described above, the set of access nodes 17 within each of the access node groups 19 provide highly-programmable, specialized I/O processing circuits for handling networking and communications operations on behalf of servers 12. In addition, in some examples, each of access node groups 19 may include storage devices 27, such as solid state drives (SSDs) and/or hard disk drives (HDDs), configured to provide network accessible storage for use by applications executing on the servers 12. In some examples, one or more of the SSDs may comprise non-volatile memory (NVM) or flash memory. Each access node group 19, including its set of access nodes 17 and storage devices 27, and the set of servers 12 supported by the access nodes 17 of that access node group 19 may be referred to herein as a network storage compute unit.

As further described herein, in one example, each access node 17 is a highly programmable I/O processor (referred to as a data processing unit, or DPU) specially designed for offloading certain functions from servers 12. In one example, each access node 17 includes a number of internal processor clusters, each including two or more processing cores and equipped with hardware engines that offload cryptographic functions, compression and decompression, regular expression (RegEx) processing, data storage functions, and networking operations. In this way, each access node 17 includes components for fully implementing and processing network and storage stacks on behalf of one or more servers 12. In addition, access nodes 17 may be programmatically configured to serve as a security gateway for its respective servers 12, freeing up the processors of the servers to dedicate resources to application workloads. In some example implementations, each access node 17 may be viewed as a network interface subsystem that implements full offload of the handling of data packets (with zero copy in server memory) and storage acceleration for the attached server systems. In one example, each access node 17 may be implemented as one or more application-specific integrated circuit (ASIC) or other hardware and software components, each supporting a subset of the servers. Additional example details of various example DPUs are described in U.S. Provisional Patent Application No. 62/559,021, filed Sep. 15, 2017, entitled “Access Node for Data Centers,” and U.S. Provisional Patent Application No. 62/530,691, filed Jul. 10, 2017, entitled “Data Processing Unit for Computing Devices,” the entire contents of both being incorporated herein by reference.

In accordance with the techniques of this disclosure, any or all of access nodes 17 may include a regular expression (RegEx) accelerator unit. That is, one or more computing devices may include an access node including one or more RegEx accelerator units, according to the techniques of this disclosure.

The RegEx accelerator unit of the access node, according to the techniques of this disclosure, may be configured to process payloads of packets during various services as the packets are exchanged by access nodes 17, e.g., between access nodes 17 via switch fabric 14 and/or between servers 12. That is, as packets are exchanged between the devices, either for networking or data storage and retrieval, the access node may perform an evaluation service on payloads of the packet. For example, the access node may provide evaluation services in the form of intrusion detection, intrusion prevention, intrusion detection and prevention (IDP), anti-virus scanning, search, indexing, or the like. The access node may use one or more RegEx accelerator units to identify patterns in payload data, such as virus definitions, attempted intrusions, search strings, indexing strings, or the like. The patterns may be defined according to respective regular expressions. According to the techniques of this disclosure, each of the RegEx accelerator units may include a hardware implementation of a regular expression evaluator, which may construct one or more deterministic finite automata (DFAs) according to the regular expressions for the patterns.

In the example of FIG. 1, each access node 17 provides connectivity to switch fabric 14 for a different group of servers 12 and may be assigned respective IP addresses and provide routing operations for the servers 12 coupled thereto. Access nodes 17 may interface with and utilize switch fabric 14 so as to provide full mesh (any-to-any) interconnectivity such that any of servers 12 may communicate packet data for a given packet flow to any other of the servers using any of a number of parallel data paths within the data center 10. In addition, access nodes 17 described herein may provide additional services, such as storage (e.g., integration of solid-state storage devices), security (e.g., encryption), acceleration (e.g., compression), I/O offloading, and the like. In some examples, one or more of access nodes 17 may include storage devices, such as high-speed solid-state drives or rotating hard drives, configured to provide network accessible storage for use by applications executing on the servers. More details on the example data center network architecture and interconnected access nodes illustrated in FIG. 1 are available in U.S. patent application Ser. No. 15/939,227, filed Mar. 28, 2018, entitled “Non-Blocking Any-to-Any Data Center Network with Packet Spraying Over Multiple Alternate Data Paths,” (Attorney Docket No. 1242-002US01), the entire content of which is incorporated herein by reference.

Various example architectures of access nodes 17 are described below with respect to FIGS. 2, 3, 4A, and 4B. With respect to either example, the architecture of each access node 17 comprises a multiple core processor system that represents a high performance, hyper-converged network, storage, and data processor and input/output hub. The architecture of each access node 17 is optimized for high performance and high efficiency stream processing.

In general, a stream, also referred to as a data stream, may be viewed as an ordered, unidirectional sequence of computational objects that can be of unbounded or undetermined length. In a simple example, a stream originates in a producer and terminates at a consumer, is operated on sequentially, and is flow-controlled. In some examples, a stream can be defined as a sequence of stream fragments, each representing a portion of data communicated by a stream. In one example, a stream fragment may include a memory block contiguously addressable in physical address space, an offset into that block, and a valid length. Streams can be discrete, such as a sequence of packets received from a network, or continuous, such as a stream of blocks, words, or bytes read from a storage device. A stream of one type may be transformed into another type as a result of processing. Independent of the stream type, stream manipulation requires efficient fragment manipulation. An application executing on one of access nodes 17 may operate on a stream in three broad ways: the first is protocol processing, which consists of operating on control information or headers within the stream; the second is payload processing, which involves significant accessing of the data within the stream; and third is some combination of both control and data access.

Stream processing is a specialized type of conventional general-purpose processing supporting specialized limitations with regard to both access and directionality. Processing typically only accesses a limited portion of the stream at any time, called a “window,” within which it may access random addresses. Objects outside of the window are not accessible through a streaming interface. In contrast, general purpose processing views the whole memory as randomly accessible at any time. In addition, stream processing generally progresses in one direction, called the forward direction. These characteristics make stream processing amenable to pipelining, as different processors within one of access nodes 17 can safely access different windows within the stream.

As described herein, data processing units of access nodes 17 may process stream information by managing “work units.” In general, a Work Unit (WU) is a container that is associated with a stream state and used to describe (i.e. point to) data within a stream (stored in memory) along with any associated meta-data and operations to be performed on the data. In the example of FIG. 1, streams of data units may dynamically originate within a peripheral unit of one of access nodes 17 (e.g. injected by a networking unit, a host unit, or a solid state drive interface), or within a processor of the one of access nodes 17, in association with one or more streams of data, and terminate at another peripheral unit or another processor of the one of access nodes 17. Each work unit maintained by a data processing unit is associated with an amount of work that is relevant to the entity executing the work unit for processing a respective portion of a stream.

Stream processing is typically initiated as a result of receiving one or more data units associated with respective portions of the stream and constructing and managing work units for processing respective portions of the data stream. In protocol processing, a portion would be a single buffer (e.g. packet), for example. Within access nodes 17, work units may be executed by processor cores, hardware blocks, I/O interfaces, or other computational processing units. For instance, a processor core of an access node 17 executes a work unit by accessing the respective portion of the stream from memory and performing one or more computations in accordance with the work unit. A component of the one of access nodes 17 may receive, execute or generate work units. A succession of work units may define how the access node processes a flow, and smaller flows may be stitched together to form larger flows.

For purposes of example, DPUs of or within each access node 17 may execute an operating system, such as a general-purpose operating system (e.g., Linux or other flavor of Unix) or a special-purpose operating system, that provides an execution environment for data plane software for data processing. Moreover, each DPU may be configured to utilize a work unit (WU) stack data structure (referred to as a ‘WU stack’ in a multiple core processor system. As described herein, the WU stack data structure may provide certain technical benefits, such as helping manage an event driven, run-to-completion programming model of an operating system executed by the multiple core processor system. The WU stack, in a basic form, may be viewed as a stack of continuation WUs used in addition to (not instead of) a program stack maintained by the operating system as an efficient means of enabling program execution to dynamically move between cores of the access node while performing high-rate stream processing. As described below, a WU data structure is a building block in the WU stack and can readily be used to compose a processing pipeline and services execution in a multiple core processor system. The WU stack structure carries state, memory, and other information in auxiliary variables external to the program stack for any given processor core. In some implementations, the WU stack may also provide an exception model for handling abnormal events and a ‘success bypass’ to shortcut a long series of operations. Further, the WU stack may be used as an arbitrary flow execution model for any combination of pipelined or parallel processing.

As described herein, access nodes 17 may process WUs through a plurality of processor cores arranged as processing pipelines within access nodes 17, and such processing cores may employ techniques to encourage efficient processing of such work units and high utilization of processing resources. For instance, a processing core (or a processing unit within a core) may, in connection with processing a series of work units, access data and cache the data into a plurality of segments of a level 1 cache associated with the processing core. In some examples, a processing core may process a work unit and cache data from non-coherent memory in a segment of the level 1 cache. The processing core may also concurrently prefetch data associated with a work unit expected to be processed in the future into another segment of the level 1 cache associated with the processing core. By prefetching the data associated with the future work unit in advance of the work unit being dequeued from a work unit queue for execution by the core, the processing core may be able to efficiently and quickly process a work unit once the work unit is dequeued and execution of the work unit is to commence by the processing core. More details on work units and stream processing by data processing units of access nodes are available in U.S. Provisional Patent Application No. 62/589,427, filed Nov. 21, 2017, entitled “Work Unit Stack Data Structures in Multiple Core Processor System,” and U.S. Provisional Patent Application No. 62/625,518, entitled “EFFICIENT WORK UNIT PROCESSING IN A MULTICORE SYSTEM”, filed Feb. 2, 2018, the entire contents of both being incorporated herein by reference.

As described herein, the data processing units for access nodes 17 includes one or more specialized hardware-based accelerators configured to perform acceleration for various data-processing functions, thereby offloading tasks from the processing units when processing work units. That is, each accelerator is programmable by the processing cores, and one or more accelerators may be logically chained together to operate on stream data units, such as by providing cryptographic functions, compression and regular expression (RegEx) processing, data storage functions and networking operations. This disclosure describes a programmable, hardware-based accelerator unit configured to apply and evaluate regular expressions against high-speed data streams. The accelerator unit may include a hardware implementation of a regular expression (RegEx) evaluator, and thus, may be referred to herein as a RegEx accelerator unit, or simply a RegEx accelerator. In particular, the RegEx accelerator unit may be configured to process one or more deterministic finite automata (DFA) to evaluate regular expressions against particular data units of the data streams.

In some examples, the RegEx accelerator unit is configured to speculatively access an internal cache of the RegEx accelerator unit to evaluate a payload. That is, the RegEx accelerator unit may include a cache (e.g., a L1 cache) that is configured to enable access to multiple portions of the cache simultaneously. For example, the cache may include two input ports and two output ports and be configured to concurrently receive two different hash keys and in response, output two different results based on the inputted keys in parallel. The RegEx accelerator unit may store two or more “node representations” of nodes of a DFA graph in the cache. In this way, rather than access a memory of the RegEx accelerator unit that stores an entire DFA graph, the RegEx accelerator unit may operate more efficiently and with lower latency by accessing multiple node representations in its internal cache, in parallel.

FIG. 2 is a block diagram illustrating an example data processing unit (DPU) 130 including two or more processing cores, in accordance with the techniques of this disclosure. DPU 130 generally represents a hardware chip implemented in digital logic circuitry and may be used in any computing or network device. DPU 130 may operate substantially similar to and generally represent any of access nodes 17 of FIG. 1. Thus, DPU 130 may be communicatively coupled to one or more network devices, server devices (e.g., servers 12), random access memory, storage media (e.g., solid state drives (SSDs)), a data center fabric (e.g., switch fabric 14), or the like, e.g., via PCI-e, Ethernet (wired or wireless), or other such communication media. Moreover, DPU 130 may be implemented as one or more application-specific integrated circuit (ASIC), may be configurable to operate as a component of a network appliance or may be integrated with other DPUs within a device.

In the illustrated example of FIG. 2, DPU 130 includes a multi-core processor 132 having a plurality of programmable processing cores 140A-140N (“cores 140”) coupled to an on-chip memory unit 134. Each of cores 140 includes a level 1 cache 141 (level 1 caches 141 a, 141 b, and 141 n are associated with cores 140 a, 140 b, and 140 n, respectively).

Memory unit 134 may include two types of memory or memory devices, namely coherent cache memory 136 and non-coherent buffer memory 138. Processor 132 also includes a networking unit 142, work unit (WU) queues 143, a memory controller 144, and accelerators 146. As illustrated in FIG. 2, each of cores 140, networking unit 142, WU queues 143, memory controller 144, memory unit 134, and accelerators 146 are communicatively coupled to each other. Processor 132 of DPU 130 further includes one or more accelerators 146 configured to perform acceleration for various data-processing functions, such as look-ups, matrix multiplication, cryptography, compression, regular expressions, or the like.

In this example, DPU 130 represents a high performance, hyper-converged network, storage, and data processor and input/output hub. For example, networking unit 142 may be configured to receive one or more data packets from and transmit one or more data packets to one or more external devices, e.g., network devices. Networking unit 142 may perform network interface card functionality, packet switching, and the like, and may use large forwarding tables and offer programmability. Networking unit 142 may expose Ethernet ports for connectivity to a network, such as switch fabric 14 of FIG. 1. DPU 130 may also include one or more interfaces for connectivity to host devices (e.g., servers) and data storage devices, e.g., solid state drives (SSDs) via PCIe lanes. DPU 130 may further include one or more high bandwidth interfaces for connectivity to off-chip external memory.

Processor 132 further includes accelerators 146 configured to perform acceleration for various data-processing functions, such as look-ups, matrix multiplication, cryptography, compression, regular expressions, or the like. For example, accelerators 146 may comprise hardware implementations of look-up engines, matrix multipliers, cryptographic engines, compression engines, or the like. The functionality of different hardware accelerators is described is more detail below with respect to FIG. 4. In accordance with the techniques of this disclosure, at least one of accelerators 146 represents a hardware implementation of a regular expression engine. In particular, according to the techniques of this disclosure, accelerators 146 include at least one RegEx accelerator that includes one or more DFA engines configured to execute DFAs representing regular expressions, as discussed in greater detail below.

Memory controller 144 may control access to on-chip memory unit 134 by cores 140, networking unit 142, and any number of external devices, e.g., network devices, servers, external storage devices, or the like. Memory controller 144 may be configured to perform a number of operations to perform memory management in accordance with the present disclosure. For example, memory controller 144 may be capable of mapping accesses from one of the cores 140 to either of coherent cache memory 136 or non-coherent buffer memory 138. More details on the bifurcated memory system included in the DPU are available in U.S. Provisional Patent Application No. 62/483,844, filed Apr. 10, 2017, and titled “Relay Consistent Memory Management in a Multiple Processor System,” (Attorney Docket No. FUNG-00200/1242-008USP1), the entire content of which is incorporated herein by reference.

Cores 140 may comprise one or more microprocessors without interlocked pipeline stages (MIPS) cores, reduced instruction set computing (RISC) cores, advanced RISC machine (ARM) cores, performance optimization with enhanced RISC—performance computing (PowerPC) cores, RISC Five (RISC-V) cores, or complex instruction set computing (CISC or x86) cores. Each of cores 140 may be programmed to process one or more events or activities related to a given data packet such as, for example, a networking packet or a storage packet. Each of cores 140 may be programmable using a high-level programming language, e.g., C, C++, or the like.

Each of level 1 caches 141 may include a plurality of cache lines logically or physically divided into cache segments. Each of level 1 caches 141 may be controlled by a load/store unit also included within the core. The load/store unit may include logic for loading data into cache segments and/or cache lines from non-coherent buffer memory 138 and/or memory external to DPU 130. The load/store unit may also include logic for flushing cache segments and/or cache lines to non-coherent buffer memory 138 and/or memory external to DPU 130. In some examples, the load/store unit may be configured to prefetch data from main memory during or after a cache segment or cache line is flushed.

As described herein, processor cores 140 may be arranged as processing pipelines, and such processing cores may employ techniques to encourage efficient processing of such work units and high utilization of processing resources. For instance, any of processing cores 140 (or a processing unit within a core) may, in connection with processing a series of work units retrieved from WU queues 143, access data and cache the data into a plurality of segments of level 1 cache 141 associated with the processing core. In some examples, a processing core 140 may process a work unit and cache data from non-coherent memory 138 in a segment of the level 1 cache 141. As described herein, concurrent with execution of work units by cores 140, a load store unit of memory controller 144 may be configured to prefetch, from non-coherent memory 138, data associated with work units within WU queues 143 that are expected to be processed in the future, e.g., the WUs now at the top of the WU queues and next in line to be processed. For each core 140, the load store unit of memory controller 144 may store the prefetched data associated with the WU to be processed by the core into a standby segment of the level 1 cache 141 associated with the processing core 140.

In some examples, the plurality of cores 140 executes instructions for processing a plurality of events related to each data packet of one or more data packets, received by networking unit 142, in a sequential manner in accordance with one or more work units associated with the data packets. As described above, work units are sets of data exchanged between cores 140 and networking unit 142 where each work unit may represent one or more of the events related to a given data packet.

As one example use case, stream processing may be divided into work units executed at a number of intermediate processors between source and destination. Depending on the amount of work to be performed at each stage, the number and type of intermediate processors that are involved may vary. In processing a plurality of events related to each data packet, a first one of the plurality of cores 140, e.g., core 140A may process a first event of the plurality of events. Moreover, first core 140A may provide to a second one of plurality of cores 140, e.g., core 140B a first work unit of the one or more work units. Furthermore, second core 140B may process a second event of the plurality of events in response to receiving the first work unit from first core 140B.

As another example use case, transfer of ownership of a memory buffer between processing cores may be mediated by a work unit message delivered to one or more of processing cores 140. For example, the work unit message may be a four-word message including a pointer to a memory buffer. The first word may be a header containing information necessary for message delivery and information used for work unit execution, such as a pointer to a function for execution by a specified one of processing cores 140. Other words in the work unit message may contain parameters to be passed to the function call, such as pointers to data in memory, parameter values, or other information used in executing the work unit.

In one example, receiving a work unit is signaled by receiving a message in a work unit receive queue (e.g., one of WU queues 143). The one of WU queues 143 is associated with a processing element, such as one of cores 140, and is addressable in the header of the work unit message. One of cores 140 may generate a work unit message by executing stored instructions to addresses mapped to a work unit transmit queue (e.g., another one of WU queues 143). The stored instructions write the contents of the message to the queue. The release of a work unit message may be interlocked with (gated by) flushing of the core's dirty cache data and in some examples, prefetching into the cache of data associated with another work unit for future processing.

FIG. 3 is a block diagram illustrating one example of a DPU 150 including a networking unit, at least one host unit, and two or more processing clusters. DPU 150 may operate substantially similar to any of the access nodes 17 of FIG. 1. Thus, DPU 150 may be communicatively coupled to a data center fabric (e.g., switch fabric 14), one or more server devices (e.g., servers 12), storage media (e.g., SSDs), one or more network devices, random access memory, or the like, e.g., via PCI-e, Ethernet (wired or wireless), or other such communication media in order to interconnect each of these various elements. DPU 150 generally represents a hardware chip implemented in digital logic circuitry. As various examples, DPU 150 may be provided as an integrated circuit mounted on a motherboard of a computing, networking and/or storage device or installed on a card connected to the motherboard of the device.

In general, DPU 150 represents a high performance, hyper-converged network, storage, and data processor and input/output hub. As illustrated in FIG. 3, DPU 150 includes networking unit 152, processing clusters 156A-1 to 156N-M (processing clusters 156), host units 154A-1 to 154B-M (host units 154), and central cluster 158, and is coupled to external memory 170. Each of host units 154, processing clusters 156, central cluster 158, and networking unit 152 may include a plurality of processing cores, e.g., MIPS cores, ARM cores, PowerPC cores, RISC-V cores, or CISC or x86 cores. External memory 170 may comprise random access memory (RAM) or dynamic random access memory (DRAM).

As shown in FIG. 3, host units 154, processing clusters 156, central cluster 158, networking unit 152, and external memory 170 are communicatively interconnected via one or more specialized network-on-chip fabrics. A set of direct links 162 (represented as dashed lines in FIG. 3) forms a signaling network fabric that directly connects central cluster 158 to each of the other components of DPU 150, that is, host units 154, processing clusters 156, networking unit 152, and external memory 170. A set of grid links 160 (represented as solid lines in FIG. 3) forms a data network fabric that connects neighboring components (including host units 154, processing clusters 156, networking unit 152, and external memory 170) to each other in a two-dimensional grid.

Networking unit 152 has Ethernet interfaces 164 to connect to the switch fabric, and interfaces to the data network formed by grid links 160 and the signaling network formed by direct links 162. Networking unit 152 provides a Layer 3 (i.e., OSI networking model Layer 3) switch forwarding path, as well as network interface card (NIC) assistance. One or more hardware direct memory access (DMA) engine instances (not shown) may be attached to the data network ports of networking unit 152, which are coupled to respective grid links 160. The DMA engines of networking unit 152 are configured to fetch packet data for transmission. The packet data may be in on-chip or off-chip buffer memory (e.g., within buffer memory of one of processing clusters 156 or external memory 170), or in host memory.

Host units 154 each have PCI-e interfaces 166 to connect to servers and/or storage devices, such as SSD devices. This allows DPU 150 to operate as an endpoint or as a root. For example, DPU 150 may connect to a host system (e.g., a server) as an endpoint device, and DPU 150 may connect as a root to endpoint devices (e.g., SSD devices). Each of host units 154 may also include a respective hardware DMA engine (not shown). Each DMA engine is configured to fetch data and buffer descriptors from host memory, and to deliver data and completions to host memory.

DPU 150 provides optimizations for stream processing. DPU 150 executes an operating system that facilitates run-to-completion processing, which may eliminate interrupts, thread scheduling, cache thrashing, and associated costs. For example, an operating system may run on one or more of processing clusters 156. Central cluster 158 may be configured differently from processing clusters 156, which may be referred to as stream processing clusters. In one example, central cluster 158 executes the operating system kernel (e.g., Linux kernel) as a control plane. Processing clusters 156 may function in run-to-completion thread mode of a data plane software stack of the operating system. That is, processing clusters 156 may operate in a tight loop fed by work unit queues associated with each processing core in a cooperative multi-tasking fashion.

DPU 150 operates on work units (WUs) that associate a buffer with an instruction stream to reduce dispatching overhead and allow processing by reference to minimize data movement and copy. The stream-processing model may structure access by multiple processors (e.g., processing clusters 156) to the same data and resources, avoid simultaneous sharing, and therefore, reduce contention. A processor may relinquish control of data referenced by a work unit as the work unit is passed to the next processor in line. Central cluster 158 may include a central dispatch unit responsible for work unit queuing and flow control, work unit and completion notification dispatch, and load balancing and processor selection from among processing cores of processing clusters 156 and/or central cluster 158.

As described above, work units are sets of data exchanged between processing clusters 156, networking unit 152, host units 154, central cluster 158, and external memory 170. Each work unit may be represented by a fixed length data structure, or message, including an action value and one or more arguments. In one example, a work unit message includes four words, a first word having a value representing an action value and three additional words each representing an argument. The action value may be considered a work unit message header containing information necessary for message delivery and information used for work unit execution, such as a work unit handler identifier, and source and destination identifiers of the work unit. The other arguments of the work unit data structure may include a frame argument having a value acting as a pointer to a continuation work unit to invoke a subsequent work unit handler, a flow argument having a value acting as a pointer to state that is relevant to the work unit handler, and a packet argument having a value acting as a packet pointer for packet and/or block processing handlers.

In some examples, one or more processing cores of processing clusters 180 may be configured to execute program instructions using a work unit (WU) stack. In general, a work unit (WU) stack is a data structure to help manage event driven, run-to-completion programming model of an operating system typically executed by processing clusters 156 of DPU 150, as further described in U.S. Patent Application Ser. No. 62/589,427, filed Nov. 21, 2017 (Attorney Docket No. 1242-009USP1), the entire content of which is incorporated herein by reference.

As described herein, in some example implementations, load store units within processing clusters 156 may, concurrent with execution of work units by cores within the processing clusters, identify work units that are enqueued in WU queues for future processing by the cores. In some examples, WU queues storing work units enqueued for processing by the cores within processing clusters 156 may be maintained as hardware queues centrally managed by central cluster 158. In such examples, load store units may interact with central cluster 158 to identify future work units to be executed by the cores within the processing clusters. The load store units prefetch, from the non-coherent memory portion of external memory 170, data associated with the future work units. For each core within processing clusters 156, the load store units of the core may store the prefetched data associated with the WU to be processed by the core into a standby segment of the level 1 cache associated with the processing core.

FIG. 4 is a block diagram illustrating another example processing cluster 180 including a plurality of programmable processing cores 182A-182N. Each of processing clusters 156 of DPU 150 of FIG. 3 may be configured in a manner substantially similar to that shown in FIG. 4. In the example of FIG. 4, processing cluster 180 includes cores 182A-182N (“cores 182”), a memory unit 183 including a coherent cache memory 184 and a non-coherent buffer memory 186, a cluster manager 185 including WU queue manager 187 for maintaining (e.g., within hardware registers of processing cluster 180) and manipulating WU queues 188, and accelerators 189A-189X (“accelerators 189”). Each of cores 182 includes L1 buffer cache 198 (i.e., core 182 includes L1 buffer cache 198A and in general, core 182N includes L1 buffer cache 198N). In some examples, cluster manager 185 is alternatively located within central cluster 158, and/or WU queues 188 are alternatively maintained within central cluster 158 (e.g., within hardware registers of central cluster 158).

An access node or DPU (such as access nodes 17 of FIG. 1, DPU 130 of FIG. 2, or DPU 150 of FIG. 3) may support two distinct memory systems: a coherent memory system and a non-coherent buffer memory system. In the example of FIG. 4, coherent cache memory 184 represents part of the coherent memory system while non-coherent buffer memory 186 represents part of the non-coherent buffer memory system. Cores 182 may represent the processing cores discussed with respect to DPU 150 of FIG. 3. Cores 182 may share non-coherent buffer memory 186. As one example, cores 182 may use non-coherent buffer memory 186 for sharing streaming data, such as network packets.

In general, accelerators 189 perform acceleration for various data-processing functions, such as table lookups, matrix multiplication, cryptography, compression, regular expressions, or the like. That is, accelerators 189 may comprise hardware implementations of lookup engines, matrix multipliers, cryptographic engines, compression engines, regular expression interpreters, or the like. For example, accelerators 189 may include a lookup engine that performs hash table lookups in hardware to provide a high lookup rate. The lookup engine may be invoked through work units from external interfaces and virtual processors of cores 182, and generates lookup notifications through work units. Accelerators 189 may also include one or more cryptographic units to support various cryptographic processes. Accelerators 189 may also include one or more compression units to perform compression and/or decompression.

An example process by which a processing cluster 180 processes a work unit is described here. Initially, cluster manager 185 of processing cluster 180 may queue a work unit (WU) in a hardware queue of WU queues 188. When cluster manager 185 “pops” the work unit from the hardware queue of WU queues 188, cluster manager 185 delivers the work unit to one of accelerators 189, e.g., a lookup engine. The accelerator 189 to which the work unit is delivered processes the work unit and determines that the work unit is to be delivered to one of cores 182 (in particular, core 182A, in this example) of processing cluster 180. Thus, the one of accelerators 189 forwards the work unit to a local switch of the signaling network on the DPU, which forwards the work unit to be queued in a virtual processor queue of WU queues 188.

As noted above, in accordance with the techniques of this disclosure, one or more of accelerators 189 may be configured to evaluate regular expressions. A RegEx accelerator of accelerators 189, in accordance with the techniques of this disclosure, may include a hardware-implemented DFA engine that executes one or more DFAs constructed according to target regular expressions, i.e., regular expressions to be evaluated as part of a service. That is, the DFA engine of a RegEx accelerator walks one or more DFA graphs to, effectively, compare an input search string to one or more regular expressions, to which the DFA graphs correspond, to determine whether the input search string matches any of the regular expression, as discussed in greater detail below.

After cluster manager 185 pops the work unit from the virtual processor queue of WU queues 188, cluster manager 185 delivers the work unit via a core interface to core 182A, in this example. An interface unit of core 182A then delivers the work unit to one of the virtual processors of core 182A.

Core 182A processes the work unit, which may involve accessing data, such as a network packet or storage packet, in non-coherent memory 156A and/or external memory 170. Core 182A may first look for the corresponding data in cache 198A, and in the event of a cache miss, may access the data from non-coherent memory 156A and/or external memory 170. In some examples, while processing the work unit, core 182A may store information (i.e., the network packet or data packet) associated with the work unit in an active segment of cache 198A. Further, core 182A may, while processing the work unit, prefetch data associated with a second work unit into a different, standby segment of cache 198A. When core 182A completes processing of the work unit, core 182A initiates (or causes initiation of) a cache flush for the active segment, and may also initiate prefetching of data associated with a third work unit (to be processed later) into that active segment. Core 182A (or a virtual processor within core 182A) may then swap the active segment and the standby segment so that the previous standby segment becomes the active segment for processing of the next work unit (i.e., the second work unit). Because data associated with the second work unit was prefetched into this now active segment, core 182A (or a virtual processor within core 182A) may be able to more efficiently process the second work unit. Core 182A then outputs corresponding results (possibly including one or more work unit messages) from performance of the work unit back through the interface unit of core 182A.

As described herein, in some example implementations, load store units within memory unit 183 may, concurrent with execution of work units by cores 182 within the processing cluster 180, identify work units that are enqueued in WU queues 188 for future processing by the cores. The load store units prefetch, from a non-coherent memory portion of external memory 170, data associated with the future work units and store the prefetched data associated with the WUs to be processed by the cores into a standby segment of the level 1 cache associated with the particular processing cores.

FIG. 5 is a block diagram illustrating an example regular expression (RegEx) accelerator 200, in accordance with the techniques of this disclosure. RegEx accelerator 200 may correspond to one of accelerators 146 of FIG. 2 or one of accelerators 189 of FIG. 4. In this example, RegEx accelerator 200 includes control block 202, on-chip memory dedicated for RegEx accelerator 200, referred to as buffer memory 204, deterministic finite automata (DFA) engines 206, and DFA caches 208, which operates as high-speed on-chip cache memory for caching select DFA arcs. As shown in FIG. 5, RegEx accelerator 200 is also in communication with external memory 210. External memory 210 is so named because external memory 210 is external to RegEx accelerator 200, i.e., off chip, and generally has longer memory access cycles. For example, external memory 210 may correspond to memory unit 134 of FIG. 2 (e.g., non-coherent buffer memory 138 of FIG. 2), external memory 170 of FIG. 3, or non-coherent buffer memory 186 of FIG. 4.

In general, control block 202 represents a processing unit (implemented in circuitry) that controls operation of other components of RegEx accelerator 200. For example, control block 202 may receive work units from external components (such as processing cores) to traverse a DFA (representing a regular expression) for target input data (e.g., a payload of a packet). In particular, one or more cores of a processing cluster, such as cores 182 of processing cluster 180 in FIG. 4, issue an instruction to load, and control block 202 loads, a DFA graph (or in some cases, multiple DFA graphs) that was previously compiled from a corresponding regular expression by a compiler. In this way, each DFA graph generated by the compiler corresponds to at least a portion of a regular expression and is a data structure represents the pattern and/or rule matching criteria set forth within the regular expression. As described in further detail below, after a compiler compiles regular expressions into DFA graphs, a loader may allocate data for the DFA graph to on-chip buffer memory 204 and/or external memory 210, and may optimize the structure of the data based on the particular memory to which the data will be stored when used for stream processing. In some examples, the loader allocates data for nodes of the DFA graph by traversing the DFA graph in a breadth-first manner starting from a root of the DFA graph so as to allocate the nodes of the DFA that are closer to the root first to buffer memory 204 and then to external memory 210 once buffer memory 204 is full or a pre-determined amount of buffer memory 204 will be utilized by the portion of the DFA graph allocated to the buffer memory.

After compilation, the loader stores data representing the DFA graph initially in external memory 210 or a different computer-readable storage medium for loading when needed for stream processing. In some examples, control block 202 may receive work units including instructions to retrieve at least a portion of a DFA graph from external memory 210 allocated and structurally arranged for buffer memory 204 by the loader following compilation of the regular expression. In response, control block 202 may retrieve the designated portion of the DFA graph from external memory 210 and store the portion of the DFA graph to one or more of buffer memory 204, and in some cases may preload certain nodes into high-speed, on-chip DFA caches 208, which may operate as L1 caches. Likewise, after one or more searches have been conducted, control block 202 may receive work units including instructions to clear one or more of DFA caches 208 and/or unload portions of DFAs from buffer memory 204. Furthermore, control block 202 may receive work units including instructions to initiate a search, e.g., indicating a payload to be searched using a loaded DFA graph. In some examples, a single work unit may represent both a command to load a DFA and to perform a search using the loaded DFA.

In general, a DFA graph includes a set of nodes directly linked by arcs, where each node in the graph represents a state and each arch represents transitions between states based on criteria specified for the respective arc. Each node of a DFA graph may contain one or more arcs directionally linking the node to itself and/or other nodes within the DFA graph.

As further described below, when compiling one or more regular expressions into one or more DFA graphs, the compiler may generate one or more of the nodes in a form of a hash table having a set of hash buckets for storing data indicative of the state transitions represented by the arcs originating from the node. Input, such as symbols within payloads of stream data, are hashed to hash buckets to determine whether the input results in a state transition for the given node. Moreover, the compiler may arrange each hash bucket in the form of a set of slots, and data representative of the arcs of the DFA may be stored in the slots of hash buckets. Further, when generating the DFA graph, the compiler may control and arrange the number of slots each hash bucket for a given node based on the target memory designated to store the node when the DFA graph is to be applied. For example, each of buffer memory 204 and external memory 210 are configured so as to allow a certain amount of memory to be read in a single access, generally referred to herein as a memory slice. A memory slice may, for example, represent a certain number of memory-aligned bytes in buffer memory 204 or a certain number of aligned bytes in external memory 210. Moreover, the number of bytes of buffer memory 204 allocated for memory slices may differ from that of external memory 210. In general, memory slices of external memory 210 are larger that memory slices of buffer memory 204, such that buffer memory 204 generally stores fewer bytes for memory slices than external memory 210. In one example, buffer memory 204 stores memory slices having 32 bytes of data and is 32-byte aligned, while external memory 210 stores memory slices having 64 bytes of data and is 64-byte aligned. As further described below, the compiler may construct the format and arrangement of the hash table representing a given node in a DFA graph to optimize the node for memory access based on the target memory to which the node will be allocated when used by RegEx accelerator 200 for stream processing. For example, the compiler may control the number of slots within each row of the hash table (i.e., each hash bucket) so that the row occupies a single or multiple of the memory slice for the memory selected by the compiler for storing the node when the DFA graph is loaded for use, thereby decreasing memory access times when applying the DFA graph for stream processing.

In this way, the compiler allocates a node with more arcs than the number of slots per slice to a power of 2 slices using one or more hash functions, with these nodes being referred to herein as HASH nodes. Labels for arcs from a node of the DFA graph may act as keys to the hash functions, such that DFA engines 206 execute the hash functions on the labels of the arcs. In other words, the hash functions may map the labels for the arcs to respective hash buckets, which may correspond to slots within one or more additional memory slices for a current node of the DFA graph storing, the slots of the additional memory slices storing additional arcs for the current node. Control block 202 or one of DFA engines 206 may locate data for the nodes of the DFA graph using a mode value describing in which way the node is allocated. Thus, control block 202 or one of DFA engines 206 stores retrieves data describing the mode value for a particular node.

In yet another example, the compiler may generate some of the nodes not as hash tables but instead in a more compact form such that the node can be stored within a single memory slice of the memory designated for storage of the node. The compiler, for example, may determine that a node of a DFA graph has fewer arcs than the number of slots per memory slice and may then construct the node so as to occupy a single slice. In some examples, the compiler may allocate the node for storage in the target memory in a manner that overlays the node on unused slots of a memory slice that is designated to store a hash bucket for a hash node. In other words, these nodes (referred to herein as a ‘fill node’) are constructed and allocated to memory addresses of the targeted memory so as to occupy unused slots of hash buckets of HASH nodes.

In some examples, a first subset of the nodes of a DFA graph may be stored in buffer memory 204 and transition to the remaining nodes of the DFA graph stored in external memory 201. The data representative of the arcs may, in these examples, include a locator value that indicates whether data for a respective subsequent node of the DFA graph (pointed to by the arc) is stored in buffer memory 204 or external memory 210. In this manner, DFA engines 206 may use the locator value to retrieve data for the respective subsequent arc from either buffer memory 204 or external memory 210, and store the retrieved data in, e.g., a respective one of DFA caches 208. In some examples, when the data for the subsequent node is stored in external memory 210, DFA engines 206 may retrieve the data for the subsequent node from external memory 210 and store this retrieved data to buffer memory 204.

Each of DFA engines 206 include one or more hardware threads configured to execute respective search processes according to a DFA graph. Each of the threads may include, for example, one or more respective memories (e.g., registers, caches, or the like) for storing a current node of a corresponding DFA graph and a current position of a payload data being inspected. That is, the threads may store data representing a current node locator and a payload offset. The current node locator may correspond to a value stored by a thread including a memory type (e.g., buffer memory 204 or external memory 210), address, and mode (size and layout) of the current node.

DFA engines 206 also include respective processing units for comparing a current symbol of the payload data to labels for arcs from the current node of the DFA graph. The threads of each of DFA engines 206 may share a common processing unit, or the threads may each include a corresponding processing unit. In general, the processing unit determines a node to which to transition from the current node (i.e., the node to which the arc having a label matching the current symbol of the payload data points). More particularly, given a current node locator and an input byte (i.e., the value of a current symbol of the payload data), the processing unit reads the node from the memory location indicated by the current node locator and determines an arc of the node (if any) having a label that is the same as the input byte. If the processing unit finds such an arc, the processing unit provides the next node locator for the next input byte. On the other hand, if no such arc is found, the processing unit may reinitialize the next node locator to the start node (i.e., a root of the DFA graph).

The processing unit or the thread of the corresponding one of DFA engines 206 may then update the current node locator and the payload offset. The processing unit may continue this evaluation until either the entire set of payload data has been examined without finding a match, or a resulting node of the DFA graph is a matching node. In response to reaching a matching node, the thread of the one of DFA engines 206 may return data indicating that a match has been identified.

In some examples, before evaluating payload data, DFA engines 206 may preload at least a portion of a DFA graph into buffer memory 204 from external memory 210 or a different computer-readable medium based on the memory allocation specified by the compiler for each nodes. Additionally or alternatively, DFA engines 206 may preload a portion of the DFA graph into memory of a thread of the one of DFA engines 206. In particular, DFA engines 206 may be configured to receive a DFA LOAD work unit, including instructions to direct the DFA engine to load at least a portion of a DFA graph (e.g., a root of the DFA graph, and/or other portions of the DFA graph) into buffer memory 204 and/or memory of one of the threads of the DFA engines 206. The at least portion of the DFA graph may include a root node of the DFA graph and/or data representing one or more nodes and/or arcs of the nodes of the DFA graph. Likewise, DFA engines 206 may be configured to unload a loaded portion of a DFA graph from the thread memory and/or from buffer memory 204, e.g., in response to a DFA UNLOAD work unit. The DFA UNLOAD work unit may include instructions indicating that one or more loaded arcs of a DFA graph are to be removed from thread memory and/or buffer memory 204, and/or to unlock and clear a root buffer for a DFA graph from the thread memory and/or buffer memory 204.

To perform a search, DFA engines 206 may receive a DFA SEARCH work unit including instructions to cause DFA engines 206 to select an idle thread of DFA engines 206 to be used to search payload data against a DFA graph, at least a portion of which may have been previously loaded in response to a DFA LOAD work unit. To perform the search, DFA engines 206 may provide to the idle thread: data representing locations of the DFA graph (including a root of the graph, a base address of a portion of the DFA graph loaded into buffer memory 204, and a base address of a portion of the DFA graph in external memory 210), a node from which to start the DFA graph traversal, addresses of payload buffers to be processed in a work unit stack frame, and an address and size of a result buffer in the work unit stack frame.

Accordingly, as discussed above, a thread and a processing unit of one of DFA engines 206 may perform a search in response to a DFA SEARCH work unit. In particular, the processing unit may retrieve a current symbol from payload data of the work unit stack frame, as indicated by the DFA SEARCH work unit, and ultimately output an indication of whether a match occurred to the result buffer in the work unit stack frame.

An example search algorithm is described below. Inputs to the algorithm include a location of a root of a DFA graph (root node locator), addresses of the DFA graph in buffer memory 204 and external memory 210, a starting node for the traversal of the DFA graph, payload bytes used to traverse the graph, and an address to which to write matching results. Starting from the first byte in the first payload buffer and the start node locator, a DFA thread of one of DFA engines 206 matches each payload byte (cur_label:=payload[cur offset]) with an arc to a DFA node (cur_node:=dfa_graph[cur_node locator]). The example matching algorithm, which may be performed by the processing unit of the one of DFA engines 206, is as follows:

-   -   1. If the node at cur_node locator contains an arc that maps         cur_label to a next_node_locator, then:         -   a. cur_offset←cur_offset+1         -   b. cur_node_locator←next_node_locator     -   2. If the node at cur_node_locator does NOT contain an arc for         cur_label, then:         -   a. cur_offset remains the same         -   b. cur_node_locator←root_node_locator.

After step 2 above, the processing unit matches the current payload byte to the arcs from the root node. In some examples, this match may be performed in parallel with another byte of the payload, e.g., if the root is preloaded into one of DFA cache memories 208 associated with the thread.

The following example algorithm describes one process for writing data to a result buffer. In this example, a DFA thread may add a result entry to the result buffer. If the current node arc has a MATCH attribute indicating that the subsequent node from this arc is a MATCH, the DFA thread adds data representing the current payload offset and next node locator to the result buffer.

The DFA thread may continue to match consecutive payload bytes with successive DFA nodes until either the last payload byte is processed, the result buffer becomes full, or a memory error is detected. Ultimately, DFA engines 206 may generate a return work unit including data indicating that the search has resulted in a match (but not the last match), the search has resulted in a match and it is the last match, that the result buffer is full, or an error code if an error occurred during the search. RegEx accelerator 200 may send the return work unit to the unit that issued the DFA SEARCH work unit.

Each of DFA engines 206 correspond to respective, private DFA cache memories 208. DFA cache memories 208 may serve two purposes: cache arc data (e.g., recently traversed arcs from a node for which data is stored in external memory 210), and cache root buffer data (e.g., caching pre-loaded root data from external memory 210 for parallel lookups in response to arc cache misses). An entire one of DFA cache memories 208 may be used as an arc cache, where each cache line holds one node arc. DFA engines 206 may load these node arcs and evict these node arcs dynamically in the arc cache when they are accessed and traversed by a respective DFA thread.

In addition, DFA engines 206 may use part of the respective one of DFA cache memories 208 as a software-managed root buffer, where each cache line may hold two preloaded root arcs. If a DFA graph has its root data in external memory 210, DFA engines 206 may first need to receive a DFA LOAD work unit to preload the root arcs into the root buffer before performing a search using the DFA graph. Eventually, DFA engines 206 may also need to receive a DFA UNLOAD work unit to unload the DFA arcs, once the DFA graph is no longer in use.

FIG. 6A is a conceptual diagram illustrating an example DFA graph 220. As noted above, a DFA graph represents a set of one or more corresponding regular expressions. That is, as noted above, a compiler generates the DFA graph from the corresponding one or more regular expressions. In general, DFA graphs include nodes (representing states) with arcs (directed links representing transitions) pointing from one node to another. In the example of FIG. 6A, DFA graph 220 includes nodes 222-244, with arcs having labels between the various nodes. For example, node 222 has an arc to node 224 with label ‘a.’ As another example, node 224 has an arc to node 232 with label ‘b.’ Furthermore, node 222 of DFA graph 220 represents a start node, as indicated by the label “START.” Likewise, nodes 240, 242, and 244 of DFA graph 220 represent example match nodes that match a corresponding regular expression. In the example of FIG. 6A, strings “aaa”, “abd”, and “cb” result in matches.

Although not shown in this example, other terminal and non-matching nodes (e.g., nodes 244, 234, 236, and 238) may have arcs pointing back to node 222. Alternatively, no such arcs may be needed, but instead, a processing unit of a DFA engine may be configured to transition to node 222 if no matching arc can be found for a given input byte from a current node. For example, if at node 232, an input value of ‘a’ is evaluated, the processing unit may transition back to node 222. Furthermore, various arcs may be included that interconnect the nodes of DFA graph 220. For example, node 226 may include an arc that points to node 224.

FIG. 6B is a flowchart illustrating an example method for allocating data representing nodes of a DFA graph between buffer memory 204 and external memory 210 of RegEx accelerator 200 of FIG. 5 and generating the data based on the allocation to optimize or otherwise improve memory access and utilization, in accordance with the techniques of this disclosure. The method of FIG. 6B is described as being performed by a compiler and a loader executed by one or more processing cores 182 of processing cluster 180 of FIG. 4.

Initially, the compiler receives a set of one or more regular expressions (320). The compiler compiles the regular expression into a DFA graph (322), such as DFA graph 220 of FIG. 6A.

The loader then allocates data for the nodes and arcs to slots of memory slices in buffer memory 204 and/or external memory 210, including assigning the base memory address for the node and specifying the slots to be used to store the arc data for the node. Moreover, based on the number of arcs, the loader determines whether the data representing the node will be arranged as HASH node have a plurality of hash buckets or as a FILL node occupying a portion of a single memory slice. In general, when constructing and allocating the nodes to memory by selecting the base address for each node, the loader traverses the DFA graph and allocates the larger HASH nodes first and then allocates the FILL nodes to occupy unused slots within the hash buckets of the HASH nodes. The loader allocates the data for the nodes and arcs to buffer memory 204 until buffer memory 204 is full, and then transitions the allocation to external memory 210. As noted above, buffer memory 204 and external memory 210 may have memory slices of different sizes, e.g., 32 bytes and 64 bytes, respectively, and the loader generates and structures the HASH nodes and, in particular, the size of the hash buckets, based on the particular memory to which the node is being allocated.

During the process, the loader selects a next node (e.g., initially, the start or root node) of the DFA graph and traverses the graph in breadth first order so nodes closer to the root tend to be allocated to on-chip buffer memory (324). For each node, the loader determines whether the number of arcs from the node is greater than the number of slots in a memory slice of the current memory (buffer memory 204 or external memory 210) and controls the structure of the node based on the number of arcs and the current memory to which the node is to be allocated (326).

If the number of arcs is greater than the number of slots in a memory slice (“YES” branch of 326), the loader generates the data representing the node as a hash table and stores a mode value for the current node indicating that arcs for the current node are stored in hash buckets according to one or more hash functions (328). Furthermore, the loader executes one or more hash functions (e.g., four hash functions) to determine the hash buckets to which to allocate arc data, where the size of the buckets are controlled to have a specific number of slots such that each hash bucket occupies a single or multiple of a memory slice (330). The loader then allocates data for the arcs of the current node to the resulting hash buckets (332).

On the other hand, if the number of arcs is not greater (i.e., less than or equal to) the number of slots in a memory slice (“NO” branch of 326), the loader generates the data representing the node in the form of a FILL node by determining open slots among previously allocated HASH node (334) to which to allocate arc data for the current node. That is, the loader determines a memory slice that may include a number of previously filled slots for a previous hash node, but also at least enough unallocated slots to store data for arcs of the current node. The loader then allocates the arcs of the current node to the open slots of the memory slice (336). The loader then stores a mode value indicating that the current node is allocated as a FILL node, as well as positions for arcs of the current node (338).

Tables 1 and 2 below provide examples of different fill modes for a DFA graph node, depending on whether the arcs for the node are allocated to buffer memory 204 or external memory 210. In particular, Table 1 represents an example set of fill modes for buffer memory 204 (assuming six slots per 32-byte slice of buffer memory 204), while Table 2 represents an example set of fill modes for external memory 210 (assuming ten slots per 64-byte slice of external memory 210). In Tables 1 and 2, X's represent slots to which arc data is allocated for a mode indicated by the mode value.

TABLE 1 SLOT NUMBERS MODE 5 4 3 2 1 0 1 X 2 X 3 X 4 X 5 X X 6 X X 7 X X 8 X X X 9 X X X 10 X X X 11 X X X X 12 X X X X 13 X X X X X 14 X X X X X X

TABLE 2 SLOT NUMBERS MODE 9 8 7 6 5 4 3 2 1 0 1 X 2 X 3 X 4 X 5 X 6 X 7 X X 8 X X 9 X X 10 X X 11 X X 12 X X 13 X X 14 X X 15 X X 16 X X X 17 X X X 18 X X X 19 X X X 20 X X X 21 X X X X 22 X X X X 23 X X X X X 24 X X X X X 25 X X X X X X 26 X X X X X X X 27 X X X X X X X X 28 X X X X X X X X X 29 X X X X X X X X X X

After allocating the arc data for the node according as either a HASH node or a FILL node as discussed above, the loader moves to the next node of the DFA graph (in breadth first order) (324) and proceeds to allocate the data for that node, until data for arcs of all nodes has been allocated. As noted above, in some examples, the loader traverses the DFA graph in breath-first manner and allocates HASH nodes during the traversal while setting aside FILL nodes for subsequent allocation within the unused slots of the HASH nodes. It should be understood that “allocated” refers to determining the bases addresses where the nodes and arc data are to be subsequently loaded and stored including whether the data for the arcs of the node is to be stored in external memory 210 or read into buffer memory 204, e.g., in response to a DFA LOAD WU. The loader may store such data to external memory 210 or other computer-readable medium.

FIG. 6C is a conceptual diagram illustrating an example set of memory slices 350 of buffer memory 204. In particular, the example set of memory slices 350 includes memory slices 352A-352E (memory slices 352). In this example, each of memory slices 352 includes six slots, although it should be understood that in other examples, other numbers of slots may be used. Moreover, although discussed with respect to the particular example of buffer memory 304 having 32-byte memory slices with six slots, similar techniques may apply to memory slices of external memory 310, which may be 64 byte memory slices with ten slots.

FIG. 6C also depicts an example node 354 of a DFA graph. In this example, arcs for node 354 is generated by the compiler to be stored in hash mode, such that node 354 may be viewed as a HASH node having a number of hash buckets mapped to respective memory slices 352. That is, the compiler selects and utilizes hash function 356A to map label data for node 354 to memory slice 352B, and utilizes hash function 356B to map the label data for node 354 to memory slice 352C. Data for arcs of node 354 is stored in slots of memory slices 352B, 352C as represented by diagonal hashing. As seen in this example, arc data of node 354 that hashes to a hash bucket occupying memory slice 352B only utilizes four of the six slots.

FIG. 6C further depicts another example node 358 of the DFA graph. In this example, the compiler has generated the data for representing node 358 as a FILL node, where the arcs for node 358 are stored in fill mode within unused slots of the overall hash table allocated for hash node 354. In particular, with respect to the example of Table 1 above, arcs for node 358 are stored according to fill mode 7 so as to occupy slots 0 and 1 within memory slice 352B of on-chip buffer memory. That is, arc data for node 358 is stored in slots of memory slice 352B, as represented by vertical hashing, which are unused slots of a hash bucket of HASH node 354 mapped to memory slice 352.

In this manner, the compiler or loader may allocate slots of memory slices of, e.g., buffer memory 304, to arcs for nodes of a DFA graph. The compiler may allocate slots of memory slices for external memory 310 in a similar fashion, although with the recognition that the memory slices of external memory 310 may be larger than the memory slices of buffer memory 304.

FIGS. 7A through 7C are flowcharts illustrating example regular expression operations performed in accordance with the techniques of this disclosure. The operations of the methods of FIGS. 7A through 7C may be performed by, e.g., the components of RegEx accelerator 200 as discussed below, or other devices in other examples. Furthermore, the operations of the methods of FIGS. 7A through 7C may be performed in a different order or with fewer operations than what is shown in FIGS. 7A through 7C.

As shown in FIG. 7A, initially, RegEx accelerator 200 receives a DFA LOAD work unit (WU) (250). As discussed above, the DFA LOAD work unit may specify a DFA graph to be loaded into, e.g., buffer memory 204 and/or one of DFA caches 208. The DFA LOAD work unit may also specify a portion of the DFA graph to be loaded, e.g., a root node of the DFA graph and/or one or more other nodes and corresponding arcs. In response to the DFA LOAD work unit, control block 202 may cause one of DFA engines 206 to load the indicated portion of the indicated DFA graph (252), e.g., into buffer memory 204 and/or into a corresponding one of DFA caches 208. In this manner, the one of DFA engines 206 stores at least a portion of a DFA graph to a DFA buffer of a memory, the DFA graph comprising a plurality of nodes, each of the nodes having zero or more arcs each including a respective label and pointing to a respective subsequent node of the plurality of nodes, at least one of the plurality of nodes comprising a match node.

Next, as shown in FIG. 7B, after having previously loaded the portion of the DFA graph, RegEx accelerator 200 receives a DFA SEARCH work unit (254). In some examples, RegEx accelerator 200 may receive a single work unit representing both load and search instructions. The DFA SEARCH work unit, as discussed above, specifies payload data to be compared to the DFA graph. In response to receiving the DFA SEARCH work unit, control block 202 directs the work unit to one of DFA engines 206, which assigns the search to an idle hardware thread thereof (256). The one of DFA engines 206 also initializes the DFA thread (258). For example, using data of the DFA SEARCH work unit, the one of DFA engines 206 sets a value of a current node memory for the thread to represent a current node (e.g., a start node) of the DFA graph and a value of a payload offset to represent a current byte of the payload (e.g., a starting symbol of the payload). The one of DFA engines 206 may further maintain data representing a location of a result buffer to which output data is to be written as a result of performing the search.

The DFA thread of the one of DFA engines 206 may then search symbols of the payload data against the DFA graph (260). In particular, the DFA thread may compare (or cause a processing unit of the one of DFA engines 206 to compare) the current symbol of the payload data to labels of arcs from the current node of the DFA graph. If one of the labels is the same as the current symbol, the DFA thread may update the current node value to correspond to the node pointed to by the arc having the label that is the same as the current symbol, and increment the value for the position of the current symbol, to move to a next symbol in the payload data. If none of the labels match the current symbol, the DFA thread may transition back to the start node of the DFA graph, and compare the current symbol to the arcs from the start node of the DFA graph. If the start node has been loaded into one of DFA caches 208, the DFA thread may perform the comparison of the current symbol of the payload data to the arcs from the start node in parallel to the comparisons of the current symbol to the arcs from the current node.

In this manner, the DFA thread determines a value of a current node memory representing a current node of the plurality of nodes in the DFA graph, a value of a payload offset memory representing a position of current symbol in a sequence of symbols of payload data, and a label of one of the arcs of the current node that matches the current symbol. Furthermore, in this manner, the DFA thread updates the value of the current node memory to a value representative of the respective subsequent node of the one of the arcs having the label that matches the current symbol. Likewise, in this manner, the DFA thread increments the value of the payload offset memory.

In some examples, the DFA thread may determine the label of one of the arcs of the current node that matches the current symbol by speculatively accessing a cache of RegEx accelerator 200 by accessing the two or more node representations of the DFA graph that are stored in the cache in parallel. That is, RegEx accelerator 200 may maintain in a memory, a reference node representation for the at least the portion of the DFA graph, and a respective delta node representation for each node of the at least the portion of the DFA graph other than the reference node, each respective delta node representation defining each of the zero or more arcs of a different, corresponding node from the plurality of nodes that is not defined by the representation of the reference node. As such, the DFA thread may determine a label of one of the arcs of the current node that matches the current symbol by speculatively accessing the two or more node representations in parallel to determine whether the current symbol matches the label.

The DFA thread may determine whether a match node of the DFA graph has been reached (262). The DFA thread may encounter zero, one, or more match nodes of the DFA graph, depending on the DFA graph and the payload data. In response to reaching a match node (“YES” branch of 262), the DFA thread may output data indicating that a match has occurred (264). In some examples, the DFA thread outputs data for each match that has occurred. For example, the DFA thread may write data to the result buffer, as discussed above. If no match occurs for the entire payload, in some examples, the DFA thread outputs data indicating that no match has occurred, and that the payload has ended. In this manner, in response to updating the value of the current node memory to correspond to the match node, the DFA thread outputs an indication that the payload data has resulted in a match.

In the example of FIG. 7B, it should be understood that multiple searches may be performed using the same loaded DFA graph. That is, one or more DFA threads may perform multiple searches on multiple different packet payloads using the same DFA graph after the DFA graph has been loaded, without unloading the DFA graph between searches. Furthermore, in the example of FIGS. 7A and 7B, it should be understood that, in some instances, both the load operations of FIG. 7A and the searches operations of FIG. 7B are performed concurrently in response to a single “atomic” search command.

Finally, turning to FIG. 7C, in some instances, after performing the search or after performing multiple searches according to the operations of FIG. 7B, one of the DFA engines 206 receive a DFA UNLOAD work unit (266). In response to the DFA UNLOAD work unit, the one of DFA engines 206 removes the DFA graph data from the corresponding one of DFA caches 208 and/or buffer memory 204 (268). It should be understood that the operations of FIG. 7C are optional and in some instances the DFA engines 206 may never perform the unload operations of FIG. 7B after performing the search or after performing multiple searches.

FIG. 8 is a flowchart illustrating an example method for traversing a DFA graph from one node to a next node to apply the DFA graph to stream data in accordance with the techniques of this disclosure. In particular, the flowchart of FIG. 8 represents traversing a DFA graph stored as hash nodes and/or fill nodes in a memory of the RegEx accelerator so as to apply the DFA graph to stream data units, such as packets. The method of FIG. 8 may be performed as part of the methods of FIG. 7A through 7C discussed above. For example, the method of FIG. 8 may be performed iteratively as part of step 260 of FIG. 7B. Again, and for purposes of example, the method of FIG. 8 is explained with respect to the components of RegEx accelerator 200, although other devices may be configured to perform this or a similar method.

Initially, it is assumed that a DFA thread of one of DFA engines 206 stores a value representing a current node of a DFA graph, as well as a current symbol of a payload being evaluated. For example, the DFA thread may maintain a payload offset value representing the position of a current symbol in the payload. Accordingly, the DFA thread determines a current symbol of the payload, i.e., the value (e.g., byte value) at the payload offset within the payload (280).

The DFA thread also determines a mode value for the current node of the DFA graph, i.e., whether the structure of the node and the memory layout and allocation for the node's arc data is a FILL node or a HASH node (282). In general, the mode value may indicate that the current node is either in a fill mode (i.e., all arcs from the current node are stored in a single memory slice) or a hash mode (i.e., one or more arcs from the current node are stored in slots of one or more additional memory slices). In the case that the mode value indicates that the current node is in fill mode (“FILL MODE” branch from 282), the DFA thread compares the current symbol to arc labels of arcs in slots of the memory slice (284).

The DFA thread alternatively compares the current symbol to arc labels of arcs in the slots of the memory slice in the case that the mode value indicates that the current node is in hash mode (“HASH MODE” branch from 282). That is, the DFA thread determines one or more slots of one or more additional memory slices using one or more hash functions (e.g., four hash functions) in this case. In particular, the DFA thread executes the one or more hash functions on the current symbol value (288), and the buckets resulting from execution of the hash functions correspond to slots of the one or more additional memory slices in which additional arc data for the current node is stored. Accordingly, the DFA thread also compares labels of the arc data in the slots of the one or more additional memory slices to the current symbol of the payload (290).

In either case, the DFA thread determines one of the arcs having a label that matches the current symbol of the payload. In response to determine the one of the arcs having the label that matches the current symbol, the DFA thread updates the current node of the DFA graph to the node to which the one of the arcs points (292) and increments the payload offset (294) to update the current symbol of the payload.

FIG. 9 is a block diagram illustrating an example DFA engine 300. DFA engine 300 may correspond to one of DFA engines 206 of FIG. 5. In this example, DFA engine 300 includes hardware DFA threads 302A-302C (DFA threads 302). Each of DFA threads 302 includes respective current node values 304A-304C (current node values 304) and respective payload offsets 306A-306C (payload offsets 306). In addition, DFA engine 300 includes processing unit 310.

As discussed above, DFA threads 302 generally maintain values of respective current nodes 304 and payload offsets 306 for a current search process. DFA thread 302A, for example, may store data representing a current node of a DFA graph as current node 304A, and a position of a current symbol of payload data being compared to the DFA graph as payload offset 306A. DFA thread 302A may then cause processing unit 310 to compare the value of the current symbol indicated by payload offset 306A to labels of arcs of the node represented by current node 304A. If processing unit 310 determines that a label of one of the arcs matches the value of the current symbol, DFA thread 302A may increment payload offset 306A and update the value of current node 304A to a value representing a node pointed to by the arc. On the other hand, if processing unit 310 determines that none of the labels of the arcs matches the value of the current symbol, DFA thread 302A may update the value of current node 304A to a value representing a start node of the DFA graph. If current node 304A correspond to a node of the DFA graph configured as a match node, DFA thread 302A and/or processing unit 310 may output data indicating that match has occurred.

As noted above, DFA engine 300 may be included in RegEx accelerator 200, which may be included in a processing device, such as one of access nodes 17 (FIG. 1), DPU 130 (FIG. 2), or DPU 150 (FIG. 3). Accordingly, these processing devices represent examples of a processing device including a memory including a deterministic finite automata (DFA) buffer configured to store at least a portion of a DFA graph, the DFA graph comprising a plurality of nodes, each of the nodes having zero or more arcs each including a respective label and pointing to a respective subsequent node of the plurality of nodes, at least one of the plurality of nodes comprising a match node. The processing device also includes a DFA engine implemented in circuitry, the DFA engine comprising one or more DFA threads implemented in circuitry, each of the DFA threads comprising a current node memory storing a value representing a current node of the plurality of nodes in the DFA graph, and a payload offset memory storing a value representing a position of current symbol in a sequence of symbols of payload data. The DFA engine further includes a processing unit configured to determine a label of one of the arcs of the current node that matches the current symbol, update the value of the current node memory to a value representative of the respective subsequent node of the one of the arcs having the label that matches the current symbol, and increment the value of the payload offset memory. In response to updating the value of the current node memory to correspond to the match node, the DFA engine is configured to output an indication that the payload data has resulted in a match.

FIG. 10A is a conceptual diagram illustrating a compiler/loader unit configured to incrementally compile a set of a regular expressions into a DFA graph, in accordance with the techniques of this disclosure. FIGS. 10A through 10D are described in the context of processing cluster 180 in FIG. 4, RegEx accelerator 200 of FIG. 5, and operation 322 of FIG. 6B.

In the example of FIG. 10A, one or more cores (e.g., of a processing cluster, a central processor, offline processing system, or the like), such as cores 182 of processing cluster 180 in FIG. 4, may execute compiler/loader unit 1100 to incrementally compile a set of a regular expression rules into a DFA graph, such as DFA graph 220. Compiler/loader unit 1100 is configured to received one or more sets of regular expression rules as input 1110 (e.g., text-based input in the form of one or more regular expressions) and generate, based on input 1110, a memory allocation image as output 1112 that defines where portions of the DFA graph are being stored in external memory 210 and/or buffer memory 204. A memory allocation image that is output from compiler/loader unit 1100 may indicate where portions of one or more data structures that represent a machine-dependent DFA graph is allocated to certain portions of the memory hierarchy for a hardware-based RegEx accelerator. For example, output 1112 may indicate where portions of DFA graph 220 are stored in memory of RegEx accelerator 200, such as in buffer memory 204 and/or external memory 210.

In general, compiler/loader unit 1100 comprises executable software instructions configured to construct a DFA graph based on a set of one or more regular expression rules. Compiler/loader unit 1100 maps the DFA graph to portions of a memory hierarchy of a RegEx accelerator, such as RegEx accelerator 200, that are subsequently accessed by the RegEx accelerator during regular operations, to store the DFA graph, for performing regular expression evaluations of stream data during runtime.

As shown in FIG. 10A, compiler/loader unit 1100 includes software that functionally operate as builder stage 1102 and mapper stage 1104. In general, builder stage 1102 performs some of the most computationally-intensive tasks of compiler/loader unit 1100 in order to generate a machine-independent, DFA graph representation of the one or more regular expression rules of input 1110. Mapper stage 1104 performs a series of somewhat lesser computational tasks as builder stage 1102 so as to generate a machine-dependent mapping of the DFA graph to a memory architecture of the particular example hardware-based accelerator, such as external memory 210 and/or buffer memory 204 of RegEx accelerator 200. In some examples, builder stage 1102 may take an order of magnitude (e.g., ten times) greater amount of time to generate the DFA graph from the regular expression(s) as mapper stage 1104 takes to map the DFA graph to memory. The complexity or quantity of the operations performed by builder stage 1102 may exponentially increase according to a quantity of regular expression rules that compiler/loader unit 1100 received as input. Whereas the complexity of the operations performed by mapper stage 1104 may only be linearly related to the quantity of regular expression rules received by compiler/loader unit 1100 as input. So as to prevent the quantity of operations performed by builder stage 1102 from growing exponentially every time more regular expression rules are added to a DFA graph, compiler/loader unit 1100 may cause builder stage 1102 to perform incremental compilation techniques when updating an existing DFA graph. That is, compiler/loader unit 1100 may cause builder stage 1102 to generate a supplemental DFA graph that compiler/loader unit 1100 then joins, via a union operation, with an original DFA graph before mapper stage 1104 re-maps the DFA graph to a memory.

FIG. 10B is a conceptual diagram illustrating the compiler/loader unit of FIG. 10A in more detail. In the example of FIG. 10B, input 1110 is shown as having two parts: a first rule set 1110A of one or more regular expression rules r₁ through r_(n), and a second rule set 1110B of one or more regular expression rules r₃ and r_(n+1) through r_(n+m). Compiler/loader unit 1100 may receive rule set 1110A prior to receiving rule set 1110B. In some cases, rule set 1110A may be referred to herein as an initial set of regular expression rules 1110A and rule set 1110B may be referred to herein as a subsequent set of regular expression rules 1110B having one or more additional regular expression rules, which may be new regular expressions and/or modified versions of one or more of regular expression of rules 1110A. In some cases, rule set 1110A may include more regular expression rules than rule set 1110B. In other examples, rule set 1110B may include more, an equal number, or less than the number of regular expression rules than rule set 1110A. In some examples, rule set 1110B may include modified rules to replace rules from rule set 110A. For instance, rule set 110B includes rule r3′ as a replacement for rule r3 of rule set 1110A. Regardless as to which rule set 1110A or 1110B has more regular expression rules, compiler/loader unit 1100 may perform incremental compilation techniques as described herein to generate an updated DFA graph defined by the rules of both rule set 1110A and 1110B.

For example, in response to receiving rule set 1110A, builder stage 1102 may perform a first compilation pass p₁ of the regular expression rules in rule set 1110A to generate original machine-independent DFA 1120A. To complete the first compilation pass p₁, mapper stage 1104 may generate an initial, machine-dependent memory image 1122A that defines the locations of portions of DFA 1120A when stored in external memory 210 and/or buffer memory 204 of RegEx accelerator 200.

Next, when a user wishes to introduce additional or modified regular expression rules to RegEx accelerator 200, compiler/loader unit 1100 may cause builder stage 1102 to generate supplemental DFA 1120B. That is, after generating original DFA 1120A, and in response to receiving rule set 1110B, compiler/loader unit 1100 may cause builder stage 1102 to perform a second compilation pass p₂ where builder stage 1102 generates a supplemental DFA 1120B, based only on rule set 1110B.

Compiler/loader unit 1100 reconciles supplemental machine-independent DFA 1120B with the regular expression rules already defined by original machine-independent DFA 1120A, which may be stored in memory or a non-volatile storage device, such as a storage drive. In other words, unlike other compilers that may perform time consuming operations to recompile an entire set of regular expression rules to build an updated DFA, every time new rules are added, compiler/loader unit 1100 performs incremental compilation so as to avoid recompiling an entire set of regular expression rules every time new rules are added. Moreover, by comparing the nodes and arcs of the graphs and using a union operation or other similar techniques, compiler/loader unit 1100 may combine the two graphs while eliminating any overlap between DFA 1120A and 1120B and take the overlap into account when completing compilation pass p₂ to generate subsequent machine-dependent memory image 1122B. For example, during the union operation, compiler/loader unit 1100 may replace rule r3 from the first set of rules 1110A with rule r3′ from the second set of rules 1110B. In a similar way, during a union operation, compiler/loader unit 1100 may delete a rule from the first set of rules 1110A when the second set of rules 1110B specifically calls for its deletion (e.g., r3 may be deleted as opposed to modified if r3′ from rules set 1110B does not specify a match or any additional arcs other than an arc to a root or starting node). Mapper stage 1104 may generate subsequent memory image 1122B to minimize memory consumption, by preventing locations of memories 210 and/or 204 from being used to store redundant regular expression rules that are already mapped to other locations of memories 210 and/or 204.

FIG. 10C is a conceptual diagram illustrating aspects of a builder stage of the compiler/loader unit shown in FIGS. 10A and 10B. Builder stage 1102A of FIG. 10C is described in the context of builder stage 1102 of FIGS. 10A and 10B.

Rather than recompile an entire set of regular expression rules, every time new or modified rules are received as input 1110 to compiler/loader unit 1100, compiler/loader unit 1100 performs a faster and more efficient process, referred to as incremental compilation, to incorporate the new or modified rules into a memory mapping of RegEx accelerator 200. That is, after initially generating an original machine-independent DFA 1120A based on an initial rule set 1110A of regular expression rules, compiler/loader unit 1100 may additionally generate a machine-independent supplemental DFA 1120B based on a subsequent rule set 1110B of regular expression rules. Compiler/loader unit 1100 may combine original DFA 1120A and subsequent DFA 1120B to generate a single machine-independent graph (and subsequently a machine-dependent memory map) of the regular expression rules that are defined by the original DFA 1120A and supplemental DFA 1120B.

To combine DFA 1120A with DFA 1120B, builder stage 1120A may perform a union operation between DFA 1120A and DFA 1120B. More specifically, builder stage 1120A may initially decompose each of DFA 1120A and 1120B into individual sets of finite automata (FA). For example, builder stage 1102A may walk, in parallel, both machine-independent DFA 1120A and 1120B to produce respective FA sets 1112A and 1112B where each of individual FA from FA sets 1112A and 1112B represents a different FA of, respectively, DFA 1120A and 1120B. Said differently, builder stage 1102A may concurrently (e.g., in parallel) decompose the original DFA 1120A and the supplemental DFA 1120B into respective FA sets 1112A and 1112B. As a collection, all the FA in each one of FA sets 1112A and 1112B may represent all the regular expression rules of, respectively, rule sets 1110A and 1110B.

Builder stage 1102A of compiler/loader unit 1100 may group the individual FA of FA set 1112A into multiple groups of FA. Builder stage 1102A may maintain each of the multiple groups of FA of FA set 1112A as sub-DFA 1114A and sub-DFA 1114B. For example, builder stage 1102A may group the FA representing r1 and r2 to form sub-DFA 1114A and may group the FA representing r3 and r2 to form sub-DFA 1114B.

While grouping the FA of set 1112A into multiple groups of FA, builder stage 1102A may concurrently group the individual FA of FA set 1112B into one or more groups of FA. Builder stage 1102A may maintain each of the multiple groups of FA as sub-DFA 1114C. For example, builder stage 1102A may group the FA representing rn+1 and rn+m to form sub-DFA 1114C.

For any modifications or deletions of existing rules of DFA 1120A, builder stage 1102A may replace (or delete) the existing FA with the new or modified FA. For example, as shown in FIG. 10C, builder stage 1102A may replace FA r3 with FA r3′.

By working with sub-DFA 1114A through 1114C, builder stage 1102A may determine all combinations of FA that are shared between DFA 1120A and DFA 1120B, minus any redundant FA. For instance, builder stage 1102A may compare sub-DFA 1114A through 1114C to determine any redundant sub-DFA between sub-DFA 1114A through 1114C. Builder stage 1102A may eliminate or discard any redundant sub-DFA 1114A through 1114C. Builder stage 1102A may generate graph 1124 to represent all combinations of sub-DFA that remain after discarding any redundant sub-DFA.

Graph 1124 may be a non-deterministic, making graph 1124 a non-deterministic finite automata (NFA) graph as opposed to being a DFA graph. Builder 1102A may cause graph 1124 to include a single start node that is joined via a first epsilon arc to a starting node of DFA 1120A and is further joined via a second epsilon arc to a starting node of DFA 1120B. The resultant graph 1124 is then mapped by mapper stage 1104 to a machine-dependent memory image, such as image 1122 of FIG. 10B.

To improve computational efficiency when subsequently combining sub-DFA 1114A through sub-DFA 1114C, builder stage 1102A may form similarly sized sub-DFA 1114A through sub-DFA 1114C. Said differently, builder stage 1102A may force each of sub-DFA 1114A through 1114C to have approximately equal quantities of FA. When equally sized, builder stage 1102A may more easily compare each of sub-DFA 1114A through sub-DFA 1114C.

Although not shown in FIG. 10C, builder stage 1102A may continue the grouping operations to incrementally form larger and larger sub-DFA until builder stage 1102A forms groups of similarly sized sub-DFA that can be compared and then used to form a single graph 1124. Builder stage 1102A may perform a union operation to join sub-DFA 1114A through sub-DFA 1114C to create graph 11124. The union operation may produce a single NFA 1124 that defines all FA from original DFA 1120A and supplemental DFA 1120B without any overlapping FA.

FIG. 10D is a flowchart illustrating an example method for incrementally compiling regular expressions into a DFA graph. FIG. 10D shows operations 1150-1168. Compiler/loader unit 1100 of FIGS. 10A and 10B may perform operations 1150-1168 for performing incremental compilation techniques, as described herein. FIG. 10D is described in the context of operation 322 of FIG. 6B being performed by compiler/loader unit 1100 of FIGS. 10A and 10B. In other words, compiler/loader unit 1100 may perform operations 1150-1168 in perfuming operation 322 of FIG. 6B.

In operation compiler/loader unit 1100 may receive a first set of RegEx rules (1150) for compilation. For example, compiler/loader unit 1100 may obtain rule set 1110A as input to builder stage 1102. Compiler/loader unit 1100 may generate an initial machine-independent DFA for the first set of RegEx rules (1152). For example, builder stage 1102 of compiler/loader unit 1100 may perform the operations described above to generate a data structure, such as DFA 1120A that defines the logical relationships between the different FA of rule set 1110A.

Compiler/loader unit 1100 may generate a machine-dependent memory map for the initial machine-independent DFA (1152). For example, mapper stage 1104 of compiler/loader unit 1100 may allocate portions of the data structure generated by builder stage 1102 to a memory of a RegEx accelerator, such as external memory 210 or buffer memory 204 of RegEx accelerator 200. The memory map may indicate the location that each logical part of DFA 1120A is stored memory of RegEx accelerator 200.

At some time after receiving the first set of RegEx rules (1150), compiler/loader unit 1100 may receive, as a second set of RegEx rules, one or more new or modified RegEx rules (1156) for compilation with the first set of RegEx rules that have already been compiled. To improve computational efficiency (i.e., to avoid having to recompile the rules of the first set of RegEx rules), compiler/loader unit 1100 may perform incremental compilation techniques to produce a single data structure that represents the RegEx rules from the first and second sets. In some examples, a modification to the RegEx rules may include a deletion of a previous RegEx rule or an alteration to an existing rule such that a total quantity of RegEx rules in the first set of RegEx rules may be reduced or unaltered as a result of a modification. In some examples, a new RegEx rule is added such that a total quantity of RegEx rules may be increased.

To perform incremental compilation, compiler/loader unit 1100 may start by generating a supplemental machine-independent DFA for the new or modified RegEx rules (1158). For example, builder stage 1102 of compiler/loader unit 1100 may perform the operations described above to generate a data structure, such as DFA 1120B that defines the logical relationships between the different FA of rule set 1110B.

In response to generating the supplemental DFA, compiler/loader unit 1100 may decompose the initial DFA into a first FA set of FA from the initial DFA (1160A) while concurrently decomposing the supplemental DFA into a second FA set of FA from the supplemental DFA (1160B). For example, builder stage 1102 of compiler/loader unit 1100 may traverse each element of the machine-independent DFA graphs 1120A and 1120B to produce a respective set, for each of graphs 1120A and 1120B, of the individual FA associated with each graph. Builder stage 1102 may generate FA sets 1112A and 1112B.

Compiler/loader unit 1100 may form similarly sized sub-DFA from each of the first and second sets of FA (1162). For example, builder stage 1102 of compiler/loader unit 1100 may group individual FA from FA set 1112A into similarly sized sub-DFA 1114A and 1114B. Builder stage 1102 of compiler/loader unit 1100 may group individual FA from FA set 1112B into sub-DFA 1114C. Compiler/loader unit 1100 may merge individual sub-DFAs that are associated with a single FA set into larger and larger sub-DFA until the sub-DFA of the first set of FA are similarly sized to the sub-DFA of the second set of FA. In other words, compiler/loader unit 1100 may ensure that each of sub-DFA 1114A through 1114C is similarly sized.

With similarly sized sub-DFA, compiler/loader unit 1100 may discard redundant sub-DFA (1162). For example, builder stage 1102 may compare the sub-DFA of the second set of FA (e.g., sub-DFA 1114C) to each of the sub-DFA of the first set of FA (e.g., sub-DFA 1114A and 1114B). In other words, builder stage 1102 may disregard any sub-DFA associated with the second set of FA that correspond to sub-DFA associated with the first set of FA.

Compiler/loader unit 1100 may maintain an NFA that represents a combination of sub-DFA that remain (1166) after discarding the redundant sub-DFA (1164). For example, with each of sub-DFA 1114A through 1114C similarly sized, builder 1102 may combine each of sub-DFA 1114A through 1114C to form a single data structure 1124 that represents an NFA graph with a single starting node.

Compiler/loader unit 1100 may generate a machine-dependent memory map for the NFA (1168). For example, mapper stage 1104 of compiler/loader unit 1100 may allocate portions of the data structure that represents NFA graph 1124 to external memory 210 or buffer memory 204 of RegEx accelerator 200. The memory map may indicate the location where each logical part of NFA 1124 is stored memory of RegEx accelerator 200.

Various examples have been described. These and other examples are within the scope of the following claims. 

What is claimed is:
 1. A method comprising: receiving, at a compiler/loader unit executing at a computing device, a first set of one or more regular expression rules for implementing a RegEx accelerator; generating, by the compiler/loader unit, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generating, by the compiler/loader unit, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receiving, at the compiler/loader unit, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generating, by the compiler/loader unit, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconciling, by the compiler/loader unit, the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.
 2. The method of claim 1, further comprising: outputting, by the compiler/loader unit, for use by the RegEx accelerator, the initial memory map.
 3. The method of claim 2, further comprising: outputting, by the compiler/loader unit, for use by the RegEx accelerator, and to replace the initial memory map, the updated memory map.
 4. The method of claim 3, wherein the updated memory map is generated using an alternate operation if an amount of overlap between the supplemental DFA graph and the initial DFA graph is below a threshold amount, wherein the amount of overlap is determined by the compiler/loader unit based on a quantity of redundant groups of finite automata between the initial DFA graph and the supplemental DFA graph.
 5. The method of claim 4, wherein the alternate operation comprises generating the updated memory map directly from the initial memory map by adding any unique groups of finite automata from the supplemental DFA graph to the initial memory map to enable direct generation of the updated memory map, wherein the compiler/loader unit maintains in the initial DFA graph additional information about the initial memory map including which of the unique groups of finite automata from the supplemental DFA graph that have been added to the initial memory map.
 6. The method of claim 1, wherein the updated memory map allocates the initial DFA graph and the supplemental DFA graph to one or more of: an external memory of the RegEx accelerator or a buffer memory of the RegEx accelerator.
 7. The method of claim 1, wherein reconciling the initial DFA graph with the supplemental DFA graph to generate the updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator comprises: decomposing the initial DFA graph into one or more first groups of finite automata; decomposing the supplemental DFA graph into one or more second groups of finite automata; and generating the updated memory map by removing any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata.
 8. The method of claim 7, wherein generating the updated memory map comprises: eliminating, by the compiler/loader unit, any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata.
 9. The method of claim 7, wherein each of the groups in the one or more first groups of finite automata is equally sized.
 10. The method of claim 9, wherein each of the groups in the one or more second groups of finite automata is equally sized to have a same quantity of finite automata as each of the groups in the one or more first groups of finite automata.
 11. The method of claim 7, wherein the initial DFA graph is decomposed into the one or more first groups of finite automata concurrently with decomposing the supplemental DFA graph into the one or more second groups of finite automata.
 12. The method of claim 7, wherein generating the updated memory map by removing any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata comprises maintaining a non-deterministic finite automata (NFA) graph that represents a combination of the initial DFA graph and the supplemental DFA graph.
 13. The method of claim 7, wherein reconciling the initial DFA graph with the supplemental DFA graph to generate the updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator comprises at least one of: adding a definition of a new finite automata to the memory map; modifying a definition of a previous finite automata; or deleting the previous finite automata.
 14. A computing device comprising: at least one processor configured to execute a compiler/loader unit that is configured to: receive a first set of one or more regular expression rules for implementing a RegEx accelerator; generate, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generate, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receive, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generate, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconcile the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.
 15. The computing device of claim 14, wherein the updated memory map allocates the initial DFA graph and the supplemental DFA graph to one or more of: an external memory of the RegEx accelerator or a buffer memory of the RegEx accelerator.
 16. The computing device of claim 14, wherein the compiler/loader unit is configured to reconcile the initial DFA graph with the supplemental DFA graph to generate the updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator by at least: decomposing the initial DFA graph into one or more first groups of finite automata while concurrently decomposing the supplemental DFA graph into one or more second groups of finite automata; and generating the updated memory map by removing any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata.
 17. The computing device of claim 14, wherein the compiler/loader unit is configured to generate the updated memory map by at least: eliminating any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata.
 18. The computing device of claim 17, wherein each of the groups in the one or more first groups of finite automata is equally sized.
 19. A computer-readable storage medium comprising instructions that, when executed, cause at least one processor to execute a compiler/loader unit configure to: receive a first set of one or more regular expression rules for implementing a RegEx accelerator; generate, based on the first set of regular expression rules, an initial deterministic finite automata (DFA) graph; generate, an initial memory map for allocating the initial DFA graph to a memory of the RegEx accelerator; receive, a second set of one or more regular expression rules for implementing the RegEx accelerator, the second set of one or more regular expression rules being different than the first set of one or more regular expression rules; generate, based on the second set of one or more regular expression rules, a supplemental DFA graph; and reconcile the initial DFA graph with the supplemental DFA graph to generate an updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator.
 20. The computer-readable storage medium of claim 19, wherein the updated memory map allocates the initial DFA graph and the supplemental DFA graph to one or more of: an external memory of the RegEx accelerator or a buffer memory of the RegEx accelerator.
 21. The computer-readable storage medium of claim 19, wherein the compiler/loader unit is configured to reconcile the initial DFA graph with the supplemental DFA graph to generate the updated memory map for allocating the initial DFA graph and the supplemental DFA graph to the memory of the RegEx accelerator by at least: decomposing the initial DFA graph into one or more first groups of finite automata while concurrently decomposing the supplemental DFA graph into one or more second groups of finite automata; and generating the updated memory map by removing any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata.
 22. The computer-readable storage medium of claim 19, wherein the compiler/loader unit is configured to generate the updated memory map by at least: eliminating any redundant groups of finite automata that are present in both the one or more first groups of finite automata and the one or more second groups of finite automata. 